package dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import dao.BillDao;
import entiey.Bill;
import util.JDBCUtil;
import util.ResultSetCreateObject;

public class BillDaoImpl implements BillDao,ResultSetCreateObject<Bill>{

	@Override
	public int add(Bill bill) {
		int num=JDBCUtil.executeUpdate("insert into bill (orderNo,originalPrice,discountPrice,getMoney,changeMoney)values(?,?,?,?,?)", bill.getOrderNo(),bill.getOriginalPrice(),bill.getDiscountPrice(),bill.getGetMoney(),bill.getChangeMoney());
		return num;
	}

	@Override
	public Bill create(ResultSet rs) {
		Bill bill=new Bill();
		try {
			bill.setOrderNo(rs.getString("orderNo"));
			bill.setOriginalPrice(rs.getDouble("originalPrice"));
			bill.setDiscountPrice(rs.getDouble("originalPrice"));
			bill.setGetMoney(rs.getDouble("getMoney"));
			bill.setChangeMoney(rs.getDouble("changeMoney"));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return bill;
	}

}
